
{template 'common/header'}
<style type="text/css">
	.type-child{padding-left:55px;background:url('{MODULE_URL}template/image/bg_repno.gif') no-repeat -248px -550px;}
</style>
<ul class="nav nav-tabs">
	<li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('serviceCategory', array('op' => 'post'))}">添加分类</a></li>
	<li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('serviceCategory', array('op' => 'display'))}">管理分类</a></li>
</ul>
{if $op == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
	<input type="hidden" name="parentid" value="{$parentid}" />
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title">分类详细设置</h3>
	  </div>
	  <div class="panel-body">
	  		{if !empty($parentid)}
	    	<div class="form-group">
			    <label for="" class="col-sm-2 control-label">上级分类</label>
			    <div class="col-xs-2">
			      {$parent['name']}
			    </div>
			</div>
			{/if}
			<div class="form-group">
			    <label for="displayorder" class="col-sm-2 control-label">排序</label>
			    <div class="col-xs-2">
			      <input type="text" name="displayorder" id='displayorder' class="form-control" value="{$category['displayorder']}" placeholder="排序"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="catename" class="col-sm-2 control-label">分类名称</label>
			    <div class="col-xs-2">
			      <input type="text" name="catename" class="form-control" value="{$category['name']}" id='catename' placeholder="分类名称"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="description" class="col-sm-2 control-label">分类描述</label>
			    <div class="col-xs-4">
			      <textarea name="description" class="form-control" rows='3' id='description' placeholder="分类描述">{$category['description']}</textarea>
			    </div>
			</div>
			<div class="form-group">
			    <label for="" class="col-sm-2 control-label"></label>
			    <div class="col-sm-10">
			      <input name="submit" type="submit" value="提交" class="btn btn-primary span3">
					<input type="hidden" name="token" value="{$_W['token']}" />
			    </div>
			</div>
	  </div>
	</div>
	</form>
</div>
{elseif $op == 'display'}
<div class="main">
	<div class="category">
		<form action="" method="post" onsubmit="return formcheck(this)">
		<table class="table table-hover">
			<thead>
				<tr>
					<th style="width:10px;"></th>
					<th style="width:80px;">显示顺序</th>
					<th>分类名称</th>
					<th style="width:80px;">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $category $key $row}
				{if $key<5}
				<tr>
					<td>
						{if count($children[$row['id']]) > 0}
						<a href="javascript:;">
							<i class="icon-chevron-down"></i>
						</a>
						{/if}
					</td>
					<td>
						<input type="text" class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}">
					</td>
					<td>
						<div class="type-parent">{$row['name']}&nbsp;&nbsp;
							{if empty($row['parentid'])}
							<a href="{php echo $this->createWebUrl('serviceCategory', array('parentid' => $row['id'], 'op' => 'post'))}">
								<i class="glyphicon glyphicon-plus-sign"></i> 添加子分类</a>
							{/if}
						</div>
					</td>
					<td>
					</td>
				</tr>
				{loop $children[$row['id']] $row}
				<tr>
					<td></td>
					<td><input type="text" class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}"></td>
					<td><div class="type-child">{$row['name']}&nbsp;&nbsp;</div></td>
					<td><a href="{php echo $this->createWebUrl('serviceCategory', array('op' => 'post', 'parentid'=>$row['parentid'],'id' => $row['id']))}">编辑</a>&nbsp;&nbsp;<a href="{php echo $this->createWebUrl('serviceCategory', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此分类吗？');return false;">删除</a></td>
				</tr>
				{/loop}
				{/if}
			{/loop}
				<tr>
					<td></td>
					<td colspan="4">
						<input name="submit" type="submit" class="btn btn-primary" value="提交">
						<input type="hidden" name="token" value="{$_W['token']}" />
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
{/if}
{template 'common/footer'}

